
import 'dart:async';
import 'dart:io';
import 'package:flutter/services.dart';

class FlutterScreenRecording {
  static const MethodChannel _channel = MethodChannel('flutter_screen_recording');

  static Future<String?> get platformVersion async {
    final String? version = await _channel.invokeMethod('getPlatformVersion');
    return version;
  }

  //for iOS/Macos/Android
  static Future<bool> startRecordScreen(String name, {required String titleNotification, required String messageNotification}) async {
    if(Platform.isWindows){
      return false;
    }
    final bool start = await _channel.invokeMethod('startRecordScreen', {"name": name, "audio": false});
    return start;
  }

  //for iOS/Macos/Android
  static Future<bool> startRecordScreenAndAudio(String name, {required String titleNotification,required String messageNotification}) async {
    if(Platform.isWindows){
      return false;
    }
    final bool start = await _channel.invokeMethod('startRecordScreen', {"name": name, "audio": true});
    return start;
  }

  //for Windows
  static Future<bool> startWindowsRecordScreen(String filePath, bool audioEnable) async{
    if(Platform.isWindows) {
      final bool start = await _channel.invokeMethod('startRecordScreen', {"path": filePath, "audio": audioEnable});
      return start;
    }
    return false;
  }

  static Future<String> get stopRecordScreen async {
    final String path = await _channel.invokeMethod('stopRecordScreen');
    return path;
  }

  static void globalForegroundService() {
    print("current datetime is ${DateTime.now()}");
  }
}
